<template>
  <div class="tab-contral">
    <div v-for="(item,index) in titles" :key="index" class="tab-contral-item" 
      :class="{active: index === currentIndex}">
      <span class="item" @click="itemClick(index)">{{ item }}</span>
    </div>
  </div>
</template>

<script>
export default {
  name: "TabContral",
  data(){
    return{
      currentIndex:0
    }
  },
  methods:{
    itemClick(index){
      this.currentIndex = index;
      this.$emit('tabClick',index)
    }
  },
  props: {
    titles: {
      type: Array,
      default() {
        return [];
      },
    },
  },
};
</script>

<style>

  .tab-contral{
    display: flex;
    font-size: 14px;
    text-align: center;
    height: 40px;
    line-height: 40px;
    background-color: #fff;
  }
  .tab-contral-item{
    flex: 1;
  }
  .active {
    color: var(--color-high-text);
  }
  .active span{
    border-bottom: solid 2px pink;
    padding: 6px;
  }
</style>